﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using Wechat.Dto.Request;
using Wechat.Dto.Search;
using Wechat.Manager;
using Wechat.Util.ReturnMessage;
using Wechat.Util.StateCode;
using Wechat.Util.ModelStates;
using Wechat.API.Filter;

namespace Wechat.API.Controllers
{
    /// <summary>
    /// 图片文本
    /// </summary>
    [RoutePrefix("api/imagetext"), UnUserAuthorize]
    public class ImageTextController : ApiController
    {
        public IWechatImageTextManager WechatImageTextManager { get; set; }

        #region 添加或修改微信图文消息

        /// <summary>
        /// 添加或修改微信图文消息
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [Route("insertorupdate"), HttpPost]
        public ResultMessage InsertOrUpdateImageText(WechatImageTextRequest request)
        {
            ResultMessage returnMsg = new ResultMessage()
            {
                Status = false
            };
            if (ModelState.IsValid && request != null)
            {
                returnMsg = WechatImageTextManager.InsertOrUpdateImageText(request);
            }
            else
            {
                returnMsg.Code = (int)EnumApiStateCode.ParameterValidationFailed;
                returnMsg.Message = "参数校验失败";
            }
            return returnMsg;
        }
        #endregion

        #region 删除微信图文消息
        /// <summary>
        /// 删除微信图文消息
        /// </summary>
        /// <returns></returns>
        [Route("delete"), HttpPost]
        public ResultMessage DeleteImageText(string ids)
        {
            ResultMessage returnMsg = new ResultMessage()
            {
                Status = false
            };
            if (ModelState.IsValid)
            {
                returnMsg = WechatImageTextManager.DeleteImageText(ids);
            }
            else
            {
                returnMsg.Code = (int)EnumApiStateCode.ParameterValidationFailed;
                returnMsg.Message = "参数校验失败";
            }
            return returnMsg;
        }
        #endregion

        #region 获取微信图文信息

        /// <summary>
        /// 获取微信图文消息列表
        /// </summary>
        /// <param name="Search"></param>
        /// <returns></returns>
        [Route("get"), HttpPost]
        public ResultMessage GetImageText(WechatImageTextSearch Search)
        {
            ResultMessage returnMsg = new ResultMessage()
            {
                Status = false
            };
            if (ModelState.IsValid)
            {
                returnMsg = WechatImageTextManager.GetWechatImageTextList(Search);
            }
            else
            {
                returnMsg.Code = (int)EnumApiStateCode.ParameterValidationFailed;
                returnMsg.Message = "参数校验失败";
            }
            return returnMsg;
        }
        #endregion

        #region 获取微信图文信息列表

        /// <summary>
        /// 获取微信图文信息列表
        /// </summary>
        /// <returns></returns>
        [Route("getlist"),HttpPost]
        public ResultMessage GetImageTextList(WechatImageTextSearch search)
        {
            ResultMessage returnMsg = WechatImageTextManager.GetWechatImageTextListTwo(search);

            return returnMsg;
        }
        #endregion

    }
}
